import http from "@/api";
import { ResPage } from "@/api/interface";
import {
  CreateOrderDetailParam,
  CreateOrderParam,
  EditOrderInfoParam,
  EditOrderStatusParam,
  HxOrder,
  HxOrderDetail,
  OrderPreviewList,
  PreviewOrderDetailsParam,
  QueryMyOrderListParam,
  QueryOrderDetailListParam,
  QueryOrderListParam,
  QueryOrderResult,
  QueryPreviewOrderDetailListParam
} from "@/api/interface/order";

const apiName = "Order";

/** 创建订单 */
export const createOrder = (param: CreateOrderParam) => {
  return http.post<string>(`${apiName}/CreateOrder`, param);
};

/** 填报订单明细 */
export const createOrderDetail = (param: CreateOrderDetailParam) => {
  return http.post<string>(`${apiName}/CreateOrderDetail`, param);
};

/** 查询订单列表 */
export const queryOrderList = (param: QueryOrderListParam) => {
  return http.post<ResPage<QueryOrderResult>>(`${apiName}/QueryOrderList`, param);
};

/** 查询我的订单 */
export const queryMyOrderList = (param: QueryMyOrderListParam) => {
  return http.post<ResPage<QueryOrderResult>>(`${apiName}/QueryMyOrderList`, param);
};

/** 查询订单明细 */
export const queryOrderDetailList = (param: QueryOrderDetailListParam) => {
  return http.post<ResPage<HxOrderDetail>>(`${apiName}/QueryOrderDetailList`, param);
};

/** 查询未提交的订单，给填报明细用 */
export const queryAllUnfinishedOrder = () => {
  return http.post<HxOrder[]>(`${apiName}/QueryAllUnfinishedOrder`);
};

/** 查询订单明细审核列表 */
export const queryPreviewOrderDetailList = (param: QueryPreviewOrderDetailListParam) => {
  return http.post<ResPage<OrderPreviewList>>(`${apiName}/QueryPreviewOrderDetailList`, param);
};

/** 审核订单明细 */
export const previewOrderDetails = (param: PreviewOrderDetailsParam) => {
  return http.post<string>(`${apiName}/PreviewOrderDetails`, param);
};

/** 修改订单信息 */
export const editOrderInfo = (param: EditOrderInfoParam) => {
  return http.post<string>(`${apiName}/EditOrderInfo`, param);
};

/** 修改订单状态 */
export const editOrderStatus = (param: EditOrderStatusParam) => {
  return http.post<string>(`${apiName}/EditOrderStatus`, param);
};
